/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jogo;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;

/**
 *
 * @author IVAN
 */
public class PlayIntro {

    Clip intro[] = new Clip[4];
    static int introCount = 0;
    AudioInputStream sample[] = new AudioInputStream[4];

    public PlayIntro() {


        try {


            for (int i = 0; i < intro.length; i++) {
                //sample[i] = AudioSystem.getAudioInputStream(this.getClass().getResource("son/explosao.wav"));
                sample[i] = AudioSystem.getAudioInputStream(this.getClass().getClassLoader().getResource("son/intro.wav"));

                intro[i] = AudioSystem.getClip();
                intro[i].open(sample[i]);
            }


        } catch (UnsupportedAudioFileException ex) {
            Logger.getLogger(PlayWav.class.getName()).log(Level.SEVERE, null, ex);
        } catch (LineUnavailableException ex) {
            Logger.getLogger(PlayWav.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(PlayWav.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void playIntroducao() {
        intro[introCount].stop();
        intro[introCount].setFramePosition(0);
        intro[introCount].start();

        introCount++;

        if (introCount == 3) {
            introCount = 0;
        }

    }

    public void pauseIntroducao() {
        if (introCount > 0) {
            introCount--;
        }


        intro[introCount].stop();
        intro[introCount].setFramePosition(0);
    }
}
